﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace NNLInterface
{
    public partial class frmInformation : NNLInterface.frmBaseToolXC
    {

        private DataTable  dtnew;
        private string sourcedata;

        public frmInformation()
        {
            InitializeComponent();
        }




        public frmInformation(DataTable dt, string title, string sourceData)
        {
            InitializeComponent();
            dtnew = dt;
            this.Text = title;
            sourcedata = sourceData;
            this.barInformation.Visible = false;
        }

        private void frmInformation_Load(object sender, EventArgs e)
        {
            this.ListGrid.MenuManager = this.barmanager;
            common.SubShowList(dtnew, this.ListGrid, this.ListView, false);
            this.ListView.BestFitColumns();
            this.SetToolVisible(common.ToolVisible.Information);
            this.SearchButtonVisibility=false;
            for (int i = 0; i < this.ListView.Columns.Count - 1; i++)
            {
                this.ListView.Columns[i].OptionsColumn.ReadOnly = true;
            }
            common.subIniGrid(this.ListView, common.enumGridStyle.ViewReportStyle);
            common.GetResourceString(this, this.Name + sourcedata);
            common.ReStoreLayOut(ListView, this.Name);
        }

        private void frmInformation_ToolButtonClick(object sender, string e)
        {
            try
            {
                switch (e)
                {
                    case "excel":
                        common.ExportExcel(this.ListView);
                        break;
                    case "print":
                        common.PrintView(this.ListGrid, common.GetLanguageWord(this.Name, this.Text));
                        break;
                    default:
                        common.SaveLayout(ListView, this.Name);
                        this.Close();
                        break;

                }

            }
            catch (Exception ex)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, common.sysParameter.MessageInf, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
           
        }

        private void ListView_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
            if (e.Info.IsRowIndicator)
            {
                if (e.RowHandle >= 0)
                {
                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
                }
                else if (e.RowHandle < 0 && e.RowHandle > -1000)
                {
                    e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite;
                    e.Info.DisplayText = "G" + e.RowHandle.ToString();
                }
            }
        }


    }
}
